import { createStore } from 'vuex'; // 创建一个新的 store 实例
import persistedState from 'vuex-persistedstate';

const store = createStore({
  state() {
    return {
      count: 0,
      siderBarType: 1,
    };
  },
  mutations: {
    setSiderBarType(state, payload) {
      state.siderBarType = payload;
    },
  },
  actions: {},
  plugins: [
    persistedState({
      storage: window.sessionStorage,
      reducer(state) {
        // state就是vuex的state对象
        return {
          siderBarType: state.siderBarType,
        };
      },
    }),
  ],
});

export default store;
